
package common.util;

import java.util.Collection;

public class StringUtil {

    /**
     * 判断字符串是否为空或null
     */
    public static boolean isEmpty(CharSequence cs) {
        return org.apache.commons.lang3.StringUtils.isEmpty(cs);
    }

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.size() == 0;
    }

    /**
     * 判断字符串开头是否为中文
     */
    public static boolean isChinese(String str) {
        char[] strChar = str.toCharArray();
        char a = strChar[0];
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(a);
        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
            return true;
        }
        return false;
    }

    /**
     * 判断字符串是否为空
     */
    public static boolean isNotNull(String str) {
        if (str != null && !str.equals("") && !str.equals("null")&&!str.equals("[]")&&!str.trim().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断字符串为空
     */
    public static boolean isNull(String str) {
        if (str == null || str.equals("") || str.trim().equals("null")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断对象是否为空
     */
    public static boolean isNotNull(Object str) {
        if (str != null && !str.equals("") && !str.equals("null") && !str.equals("[]") && !str.toString().trim().equals("") && !str.toString().trim().equals("[]")) {
            return true;
        } else {
            return false;
        }
    }

}